package pheromoneMap;

public class PheromoneMapTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		PheromoneMap testMap = new PheromoneMap( 25, 25 );

		MapVisualization testVis = new MapVisualization( testMap );
		testVis.setVisible( true );

		long lastRepaint = System.currentTimeMillis();

		int locX = 10;
		int locY = 5;
		Vector2D heading = new Vector2D( 1, 0 );
		int round = 0;
		
		while( true ) {
			round++;

			Vector2D oldHeading = new Vector2D( heading );
			
			if( round % 4 == 0 )
				heading.setDirection( (heading.direction() + (Math.PI / 4) ) % (Math.PI * 2) );

			Vector2D avgHeading = new Vector2D( heading.add( oldHeading ) );
			avgHeading.update( avgHeading.multiply( 0.5 ) );
			
			locX += (int) Math.round(Math.cos(heading.direction()));
			locY += (int) Math.round(Math.sin(heading.direction()));
			
			//testMap.placePheromone( locX, locY, PheromoneType.TO_HOME, 1, avgHeading.direction() );
			testMap.placeRepulsionSquare(5, 5, PheromoneType.TO_HOME, 50, 5, 5);
			
			//testMap.coalesce( PheromoneType.TO_HOME, 1 );
			testMap.diffuse( PheromoneType.TO_HOME, 1 );
			testMap.decay( PheromoneType.TO_HOME, 1 );

			while( System.currentTimeMillis() < lastRepaint + 100 );
			testVis.repaint();
			lastRepaint = System.currentTimeMillis();
		}
	}
}
